package com.changan.controller;


import com.changan.entity.Department;
import com.changan.response.Result;
import com.changan.service.DepartmentService;
import com.changan.vo.DepartmentVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author NieChangan
 * @since 2022-03-02
 */
@CrossOrigin
@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;


    /**
     * 所有部门
     *
     * @return
     */
    @ApiOperation(value = "查询部门名称及人数")
    @GetMapping("/findDeptNameAndCount")
    public Result findDeptNameAndCount() {
        List<DepartmentVO> departmentList = departmentService.findDepartmentCountAndName();
        return Result.ok().data("departmentList",departmentList);
    }
}

